/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.treeeditpart;

import java.beans.PropertyChangeListener;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;

import com.cea.papyrus.core.editor.ModelManager;

/**
 * 
 * 
 * @author Patrick Tessier
 * 21 juin 06
 */


public class ParameterTreeEditPart extends ElementTreeEditPart
implements PropertyChangeListener {


	/**
	 * Create a new instance of this edit part using the given model element.
	 * 
	 * @param modelManager 
	 * @param model a non-null
	 */
	public ParameterTreeEditPart(org.eclipse.uml2.uml.Parameter model, ModelManager modelManager) {
		super(model,modelManager);
		// _adapter = new GefUMLAdapter();
	}

	/* (non-Javadoc)
	 * @see com.cea.papyrus.core.common.treeeditpart.ElementTreeEditPart#getCommand(org.eclipse.gef.Request)
	 */
	/**
	 * 
	 * 
	 * @param request 
	 * 
	 * @return 
	 */
	@Override
	public Command getCommand(Request request) {
		return super.getCommand(request);
	}


	/**
	 * 
	 * 
	 * @return the propety that is associated to this editpart
	 */
	public org.eclipse.uml2.uml.Parameter getParameter(){
		return (org.eclipse.uml2.uml.Parameter)element;
	}

	/**
	 * 
	 */
	class GefUMLAdapter implements Adapter {

		/**
		 * 
		 */
		private Notifier _target;

		/**
		 * 
		 * 
		 * @param notification 
		 * 
		 * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
		 */
		public void notifyChanged(Notification notification) {
			int type = notification.getEventType();

			if(Notification.REMOVING_ADAPTER != type) {
				// force refresh of the operation, parent of this parameter
				// if(getParameter().getOperation()!=null)
				// {getParameter().getOperation().setName(getParameter().getOperation().getName());}

				// getParent().refresh();
			}
		}

		/**
		 * 
		 * 
		 * @return 
		 * 
		 * @see org.eclipse.emf.common.notify.Adapter#getTarget()
		 */
		public Notifier getTarget() {
			return _target;
		}

		/**
		 * 
		 * 
		 * @param newTarget 
		 * 
		 * @see org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier)
		 */
		public void setTarget(Notifier newTarget) {
			_target = newTarget;
		}

		/**
		 * 
		 * 
		 * @param type 
		 * 
		 * @return 
		 * 
		 * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object)
		 */
		public boolean isAdapterForType(Object type) {
			return type.equals(getModel().getClass());
		}

	}

}